package org.jeecg.modules.online.cgreport.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.online.cgform.utils.CgformUtil;
import org.jeecg.modules.online.cgreport.entity.OnlCgreportParam;
import org.jeecg.modules.online.cgreport.service.IOnlCgreportParamService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping({"/online/cgreport/param"})
@RestController("onlCgreportParamController")
/* renamed from: org.jeecg.modules.online.cgreport.a.d */
/* loaded from: hibernate-re-3.7.1-RC.jar:org/jeecg/modules/online/cgreport/a/d.class */
public class OnlCgreportParamController {

    /* renamed from: a */
    private static final Logger f468a = LoggerFactory.getLogger(OnlCgreportParamController.class);
    @Autowired
    private IOnlCgreportParamService onlCgreportParamService;

    @GetMapping({"/listByHeadId"})
    /* renamed from: a */
    public Result<?> listByHeadId(@RequestParam("headId") String str) {
    	QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("cgrhead_id", str);
        queryWrapper.orderByAsc("order_num");
        List list = this.onlCgreportParamService.list(queryWrapper);
        Result result = new Result();
        result.setSuccess(true);
        result.setResult(list);
        return result;
    }

    @GetMapping({"/list"})
    /* renamed from: a */
    public Result<IPage<OnlCgreportParam>> list(OnlCgreportParam onlCgreportParam, @RequestParam(name = "pageNo", defaultValue = "1") Integer num, @RequestParam(name = "pageSize", defaultValue = "10") Integer num2, HttpServletRequest httpServletRequest) {
        Result<IPage<OnlCgreportParam>> result = new Result<>();
        Wrapper initQueryWrapper = QueryGenerator.initQueryWrapper(onlCgreportParam, httpServletRequest.getParameterMap());
        IPage page = this.onlCgreportParamService.page(new Page(num.intValue(), num2.intValue()), initQueryWrapper);
        result.setSuccess(true);
        result.setResult(page);
        return result;
    }

    @PostMapping({"/add"})
    /* renamed from: a */
    public Result<?> add(@RequestBody OnlCgreportParam onlCgreportParam) {
        this.onlCgreportParamService.save(onlCgreportParam);
        return Result.ok("添加成功!");
    }

    @PutMapping({"/edit"})
    /* renamed from: b */
    public Result<?> edit(@RequestBody OnlCgreportParam onlCgreportParam) {
        this.onlCgreportParamService.updateById(onlCgreportParam);
        return Result.ok("编辑成功!");
    }

    @DeleteMapping({"/delete"})
    /* renamed from: b */
    public Result<?> delete(@RequestParam(name = "id", required = true) String str) {
        this.onlCgreportParamService.removeById(str);
        return Result.ok("删除成功!");
    }

    @DeleteMapping({"/deleteBatch"})
    /* renamed from: c */
    public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String str) {
        this.onlCgreportParamService.removeByIds(Arrays.asList(str.split(CgformUtil.f233E)));
        return Result.ok("批量删除成功!");
    }

    @GetMapping({"/queryById"})
    /* renamed from: d */
    public Result<OnlCgreportParam> queryById(@RequestParam(name = "id", required = true) String str) {
        Result<OnlCgreportParam> result = new Result<>();
        result.setResult((OnlCgreportParam) this.onlCgreportParamService.getById(str));
        return result;
    }
}
